from selenium import webdriver
from time import sleep
bro = webdriver.Chrome()
bro.get('https://www.taobao.com/')

#标签定位
#search_input = bro.find_element_by_id('q')
search_input = bro.find_element(by='id',value='q')
#标签交互  向标签内录入一个商品名称
search_input.send_keys('iphone')
#执行一组JS代码实现滚动滚轮
bro.execute_script('window.scrollTo(0,document.body.scrollHeight)')#滚轮滚动一屏之后等待2秒钟再点击搜索按钮
sleep(2)
#点击搜索按钮
#button = bro.find_element_by_css_selector('.btn-search')
button = bro.find_element(by='class',value='tb-bg')
button.click()

bro.get('https://www.baidu.com')
sleep(2)
#回退
bro.back()
sleep(2)
#前进
bro.forward()
sleep(2)

sleep(5)
bro.quit()